const listener = {}

export default {
  $on(eventName, handler) {
    if(!listener[eventName]) {
      listener[eventName] = new Set()
    }
    listener[eventName].add(handler)
  },
  $off(eventName, handler) {
    if(!listener[eventName]) {
      return
    }
    listener[eventName].delete(handler)
  },
  $emit(eventName, ...args) {
    if(!listener[eventName]) return
    listener[eventName].forEach(handler => {
      handler(...args)
    });
  }
}

// import Vue from "vue";

// export default new Vue({})